package com.example.suspensionbardemo.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.example.suspensionbardemo.R;

import java.util.List;

public class RecyclerAdapter extends RecyclerView.Adapter<RecyclerAdapter.BaseViewHolder> {
    public List<Integer> data;
    public Context context;



    public RecyclerAdapter(Context context, List<Integer> data) {
        this.data = data;
        this.context = context;
    }

    @NonNull
    @Override
    public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.title_view, null);
        return new BaseViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
        holder.itemImg.setImageResource(data.get(position));

    }

    @Override
    public int getItemCount() {
        return data.size();
    }

    public class BaseViewHolder extends RecyclerView.ViewHolder {
        View view;
        ImageView itemImg;

        public BaseViewHolder(View view) {
            super((View) view);
            this.view = view;
            itemImg = view.findViewById(R.id.itemImg);
        }


    }
}

